#!bin/bash

func()
{
now_date=`date "+%Y-%m-%d-%H"`
success_flag_timetamp=''
yest_date=`date -d "1 hour ago" "+%Y-%m-%d"`
echo "分区日期："+$yest_date
while [ -z "$success_flag_timetamp" ]
do
  success_flag_timetamp=`hdfs dfs -stat "%Y" hdfs://yl-bg-hdp/dw/hive/jms_dm.db/external/dm_taking_timely_summary_hi/dt=$yest_date/`
  echo "检查路径：" +hdfs://yl-bg-hdp/dw/hive/jms_dm.db/external/dm_taking_timely_summary_hi/dt=$yest_date/
  echo $success_flag_timetamp
  timestmaps_check_noformat=`expr $success_flag_timetamp / 1000`
  timestmaps_check=`date -d@$timestmaps_check_noformat "+%Y-%m-%d %H:%M:%S"`
  echo "循环检查分区时间：" +$timestmaps_check
  sleep 1m
done

success_flag=`expr $success_flag_timetamp / 1000`
flag_date=`date -d@$success_flag "+%Y-%m-%d-%H"`
echo "当前时间：" $now_date
echo "更新分区时间：" $flag_date
echo "============================"
#echo $success_flag_timetamp
}
while [ $now_date != $flag_date ]
do
  #sleep 1m
  func
done
echo "success~~~"